package com.io.examples_shili;
import java.io.*;
public class FileMethods2 {
	public static void main(String[] args) {
		FileMethods2 fm = new FileMethods2();
		File file = new File("D:\\test1.txt");
		fm.create(file);//�����ļ�
		fm.showFileInfo(file);//��ʾ�ļ���Ϣ
		//fm.delete(file);//ɾ���ļ�
	}
	/**
	 * �����ļ��ķ���
	 * @param file�ļ�����
	 */
	public void create(File file) {
		if ( file.exists() ){//�ж��ļ���Ŀ¼�Ƿ����
			try {
				file.createNewFile();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println("�ļ��Ѵ��� !");
		}
	}
	/**
	 * ɾ���ļ��ķ���
	 * @param file�ļ�����
	 */
	public void delete(File file) {
		if ( file.exists() ){//�ж��ļ���Ŀ¼�Ƿ����
			file.delete();
			System.out.println("�ļ���ɾ�� !");
		}
	}
	/**
	 * ��ʾ�ļ���Ϣ
	 */
	public void showFileInfo(File file){
		if ( file.exists() ){//�ж��ļ���Ŀ¼�Ƿ����
			if ( file.isFile() ){//������ļ�
				System.out.println("����: "+file.getName());
				System.out.println("���·��: "+file.getPath());
				System.out.println("����·��: "+file.getAbsolutePath());
				System.out.println("����: "+file.length()+"�ֽ�");
			}
			if( file.isDirectory()){
				System.out.println("���ļ���Ŀ¼");
			}
		}else{
			System.out.println("�ļ�������");
		}            
	}  
}